package main

import (
	"fmt"
	"strings"
)

func main() {
	s := "AAAAAAAAAAAAA"
	fmt.Println(findRepeatedDnaSequences(s))
}

//#link: https://leetcode-cn.com/problems/repeated-dna-sequences/
func findRepeatedDnaSequences(s string) []string {
	tmpMap := make(map[string]bool)
	ans := make([]string, 0)
	for i := 0; i < len(s)-10; i++ {
		target := s[i : i+10]
		if strings.Count(s[i+1:], target) > 0 {
			if _, ok := tmpMap[target]; ok {
				continue
			} else {
				ans = append(ans, target)
				tmpMap[target] = true
			}
		}
	}
	return ans
}
